/*
* Copyright© 2018 Shanxi Lu'an Taihang Laihui Net Tech co.,LTD.
*/
package com.laihuichuxing.netty.server.server.module;

import com.laihuichuxing.netty.common.core.session.Session;
import com.laihuichuxing.netty.common.core.session.SessionManager;
import com.laihuichuxing.netty.server.server.module.login.entity.Login;
import com.laihuichuxing.socket.ModuleId;

/**
 * Description:
 *
 * @author YangGuang
 * @since: 1.0
 * Create Date Time: 2018/10/19 11:45
 * Update Date Time:
 */
public class Common {

    /**
     * Description: lsb模块通知客户端
     * @param session 当前会话
     * @param cmd 命令号
     * @author YangGuang
     * Create Date Time: 2018/10/19 11:46
     * Update Date Time:
     */
    public static void lbsNotifyClient(Session session, short cmd) {
        commonNotifyClient(session, ModuleId.LBS,cmd);
    }

    /**
     * Description: 登录模块通知客户端
     * @param session 当前会话
     * @param cmd 命令号
     * @author YangGuang
     * Create Date Time: 2018/10/19 11:56
     * Update Date Time:
     */
    public static void LoginNotifyClient(Session session,Short cmd) {
        commonNotifyClient(session,ModuleId.LOGIN,cmd);
    }

    /**
     * Description: 通用通知客户端
     * @param session 当前会话
     * @param module 模块号
     * @param cmd 命令号
     * @author YangGuang
     * Create Date Time: 2018/10/19 11:48
     * Update Date Time:
     */
    private static void commonNotifyClient(Session session, short module, short cmd) {
        Object object = session.getAttachment();
        if (object != null) {
            Login login = (Login) object;
            // 给客户端回消息
            SessionManager.sendMessage(login.getMobile(), module, cmd, null);
        }
    }
}
